<?php

namespace App\Admin\Controllers;

use App\Admin\Utils\Utils;
use App\Http\Controllers\Controller;
use App\Models\MessageTemplate;
use App\Models\Record;
use Illuminate\Http\Request;

class IhuyiController extends Controller
{
    public function getNum ()
    {
        $util = new Utils();
        return $util->balanceTheQuery();
    }

    public function addTemplate ()
    {
        $util = new Utils();
        return $util->addTemplate('这是一个测试模板');
    }

    public function templateStatus () {
        $template_id = $_POST['templateid'];
        $status = $_POST['code'];
        MessageTemplate::where(['template_id' => $template_id])->update(['status' => $status]);

        return 'success';
    }

    public function sendStatus ()
    {
        $code = $_POST['code'];
        $msg = $_POST['msg'];
        $smsid = $_POST['smsid'];

        Record::where(['smsid' => $smsid])->update(['code' => $code, 'msg' => $msg]);

        return 'success';
    }

    public function send() {
        $util = new Utils();
        return $util->sendSMS(13026422939, '您致电12345反映的问题，汉台区网格中心已受理，已分拨至相关部门，具体办理情况工作人员会和您联系，感谢您的支持。');
    }
}
